<template>
<div>
<!-- <h1>当前最新count为：{{this.$store.state.count}}</h1> -->
<!-- getters不用this -->
<h1>{{$store.getters.showNmu}}</h1>
<button @click="add">+1</button>
<button @click="addAsync(5)">+N</button>
</div>

</template>
<script>
import { mapActions } from 'vuex'
export default {
  data () {
    return {
    }
  },
  methods: {
    ...mapActions(['addAsync']),
    add () {
    //   this.$store.state.count-- 不推荐直接修改
      // 调用$store.commit来触发mutation
      this.$store.commit('add', 3)
    },
    addN (n) {
      this.$store.dispatch('addAsync', 4)
    }
  }
}
</script>

<style>

</style>
